<template>
	<view>
		<view class="wrap">
			<view class="u-tabs-box">
				<u-tabs :list="list" :is-scroll="false" inactive-color="#333" :current="current" class="utabs"
					:active-color="$lightColor" @change="changeTab"></u-tabs>
			</view>
			<swiper class="swiper-box" :current="current" @change="changeSwiper" duration="500">
				<swiper-item v-for="(item, listIndex) in list" :key="listIndex">
					<scroll-view scroll-y style="height: 100%" @scrolltolower="renderData(listIndex)">
						<view class="seller-view" v-for="(order, index) in orderList" :key="index">

							<view class="seller-info u-flex u-row-between">
								<view class="seller-name wes" @click="navigateToStore(order)">
									<view class="name wes">{{ order.storeName }}</view>
								</view>
								<view class="order-sn">
									{{order.status == 0 ? '待支付' : order.status == 1 ? '待发货' : order.status == 2 ? '待收货' : order.status == 3 ? '已发货' : '已收货' }}
								</view>
							</view>
							<view>
								<view>
									<view class="goods-item-view" @click="navigateToOrderDetail(order.id)">
										<view class="goods-img">
											<u-image border-radius="6" width="100%" height="100%"
												:src="order.image.split(',')[0]">
											</u-image>
										</view>

										<view class="goods-name">
											{{order.name}}
										</view>

										<view class="goods-price">
											¥{{order.price}}
										</view>

										<view class="goods-num">
											{{order.specifications}} x{{order.num}}
										</view>

										<view class="goods-sku">
											
										</view>

									</view>
								</view>

								<view class="shifukuan">
									实付款 ¥{{order.allPrice}}
								</view>
								<view class="btn-view u-flex" style="justify-content: flex-end;">
									<view class="goods-btn flex flex-a-c">
										<view ripple class="pay-btn" shape="circle" size="mini" v-if="current == 0"
											@click="goTopingjia(order)">去评价</view>
									</view>
								</view>
							</view>
						</view>


					</scroll-view>
				</swiper-item>
			</swiper>
		</view>
	</view>
</template>

<script>
	import {
		getOrderList
	} from "@/api/order.js";
	import storage from "@/utils/storage.js";

	export default {
		data() {
			return {
				list: [{
						name: "待评价",
					},
					{
						name: "已评价",
					},
				],
				current: 0, //当前tabIndex
				orderList: [], //商品集合
				params: {
					page: 1,
					limit: 10,
					type: 0,
				},
			};
		},

		onShow() {
			this.orderList = [];
			this.params.page = 1;
			this.current = 0
			this.loadData()
		},
		watch: {
			current(val) {
				this.params.page = 1;
				this.orderList = [];
				this.loadData();
			},
		},

		methods: {

			navigateToStore(val) {
				uni.navigateTo({
					url: "/pages/product/shopPage?id=" + val.storeId,
				});
			},
			changeTab(index) {
				this.current = index;
			},


			changeSwiper(e) {
				this.current = e.target.current;
			},
			goTopingjia(order) {
				uni.navigateTo({
					url: `/pages/business/pingjia?sn=${order.id}`
				})
			},
			loadData() {
				uni.showLoading({
					title: "加载中",
				});
				getOrderList({
					...this.params,
					userId: storage.getUserInfo().id,
					type: this.current == 0 ? 7 : 8
				}).then((res) => {
					this.orderList = [...this.orderList, ...res.data.list]
				});
			},
			renderData(index) {
				this.params.page = this.params.page + 1;
				this.loadData()
			},


		},
	};
</script>
<style lang="scss" scoped>
	page {
		height: 100%;
	}

	.tips {
		text-align: right;
		font-size: 24rpx;
		color: #999;
	}

	.wrap {
		background: #f6f6f6;
		height: calc(100vh - var(--window-top));
		width: 100%;
	}

	.goods-imgs-view {
		margin: 20rpx 0;
		display: flex;
		flex-direction: row;
		flex-wrap: wrap;
		align-items: center;

		.img-view {
			margin-right: 15rpx;
		}
	}

	.u-tabs-box {
		position: relative;
		z-index: 10;
	}

	.box-content {
		margin: 20rpx 0;
	}

	.title_seller_name {
		font-weight: 700;
		font-size: 28rpx;
		color: #333;
		padding-left: 0 !important;
	}

	.box-title {
		height: 90rpx;
		line-height: 90rpx;
	}

	.swiper-box {
		height: calc(100% - 88rpx);
	}

	.goods-specs {
		margin-bottom: 10rpx;
		color: #cccccc;
		font-size: 24rpx;
	}

	.goods-price {
		margin-bottom: 10rpx;
		color: #999999;
		font-size: 24rpx;
	}

	.goods-item-view {
		display: flex;
		margin-bottom: 20rpx;

		.goods-info {
			padding-left: 30rpx;

			.goods-title {
				color: $u-main-color;
				margin-bottom: 10rpx;
			}
		}

		.goods-num {
			margin: 0rpx 10rpx;
			display: flex;
			flex-direction: column;
			align-items: flex-end;
			justify-content: space-between;
			margin-bottom: 10rpx;

			.u-num {
				color: $aider-light-color;
				font-size: 33rpx;
			}
		}
	}

	.again-btn {
		margin: 0rpx 10rpx;
		display: flex;
		flex-direction: column;
		align-items: flex-end;
		margin-bottom: 10rpx;
	}

	.seller-view {
		background-color: #fff;
		margin: 20rpx 0px;
		padding: 0px 20rpx 20rpx 20rpx;
		border-radius: 20rpx;

		.seller-info {
			height: 70rpx;

			.seller-name {
				font-size: 33rpx;
				font-weight: 600;
			}

			.order-sn {
				color: #909399;
			}
		}

		.btn-view {
			min-height: 70rpx;
			margin: 5rpx 5rpx;
			display: flex;
			flex-direction: row;

			.description {
				size: 25rpx;
				color: #999999;

				.text {
					margin: 20rpx 0rpx;
				}

				.title {
					color: #5f5d5f;
				}
			}
		}

		.evaluate {
			padding: 20rpx 0;
			display: flex;
			justify-content: flex-end;
		}
	}


	.seller-view {
		border-radius: 20rpx;
		background-color: #fff;
		margin: 20rpx 0rpx;

		.seller-info {
			height: 70rpx;
			padding: 0 20rpx;

			.seller-name {
				flex: 10;
				font-size: 28rpx;
				font-weight: 600;
				display: flex;
				flex-direction: row;

				.name {
					margin-left: 15rpx;
					margin-top: -2rpx;
				}
			}

			.order-sn {
				flex: 2;
				width: 120rpx;
				text-align: center;
				color: $aider-light-color;
				font-size: 26rpx;
			}
		}

		.goods-item-view {
			display: flex;
			flex-wrap: wrap;
			flex-direction: row;
			padding: 10rpx 34rpx;

			position: relative;

			.goods-name {
				position: absolute;
				width: 389rpx;
				height: 55rpx;
				font-family: Microsoft YaHei;
				font-weight: 400;
				font-size: 24rpx;
				color: #000000;
				line-height: 27rpx;
				left: 178rpx;
			}

			.goods-img {
				width: 131rpx;
				height: 131rpx;
				margin-right: 10rpx;
				margin-bottom: 10rpx;
			}

			.goods-price {
				font-size: 28rpx;
				margin-bottom: 10rpx;
				position: absolute;
				right: 31rpx;
			}

			.goods-num {

				font-family: Arial;
				font-weight: 400;
				font-size: 17rpx;
				color: #999999;
				position: absolute;
				top: 60rpx;
				right: 31rpx;
			}

			.goods-sku {
				font-family: Microsoft YaHei;
				font-weight: 400;
				font-size: 25rpx;
				color: #999999;
				position: absolute;
				top: 80rpx;
				left: 178rpx;
			}

			.goods-info {
				padding-left: 30rpx;
				flex: 1;

				.goods-title {
					margin-bottom: 10rpx;
					color: #333333;
				}

				.goods-specs {
					font-size: 24rpx;
					margin-bottom: 10rpx;
					color: #cccccc;
				}


			}


		}

		.shifukuan {
			width: 100%;
			height: 65rpx;
			line-height: 65rpx;
			font-family: Arial;
			font-weight: 400;
			font-size: 21rpx;
			color: #000000;
			padding-right: 20rpx;
			text-align: right;
		}

		.btn-view {
			padding: 25rpx 30rpx;
			font-size: 26rpx;

			.description {
				display: flex;
				color: #909399;
				size: 24rpx;
				flex: 1;

				.price {
					color: $main-color;

				}
			}
		}
	}
</style>
